<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:display="http://www.w3.org/1999/xhtml"
      xmlns:div.display="http://www.w3.org/1999/xhtml" xmlns:row.display="http://www.w3.org/1999/xhtml">
<head>
    <script th:src="@{/vendor/jquery/jquery.min.js}"></script>
    <script th:src="@{/vendor/bootstrap/js/bootstrap-table.js}"></script>
    <!-- Bootstrap Core JavaScript -->
    <script th:src="@{/vendor/bootstrap/js/bootstrap.min.js}"></script>
    <!-- Metis Menu Plugin JavaScript -->
    <script th:src="@{/vendor/metisMenu/metisMenu.min.js}"></script>
    <!-- Custom Theme JavaScript -->
    <script th:src="@{/dist/js/sb-admin-2.js}"></script>
    <script th:src="@{/vendor/datepicker/bootstrap-datepicker.js}"></script>
    <link href="/vendor/bootstrap/css/bootstrap-table.css" rel="stylesheet">
    <link href="/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- MetisMenu CSS -->
    <link href="/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="/dist/css/sb-admin-2.css" rel="stylesheet">
    <link href="/vendor/datepicker/datepicker3.css" rel="stylesheet">
    <!-- Custom Fonts -->
    <link href="/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Tbluser_Properties</title>

    <!-- Bootstrap Core CSS -->


</head>

<!--onload="getCustCode()"-->
<body>

<div id="page-Tbluser_Properties">
    <ul id="myTab" class="nav nav-tabs">
        <li class="active">
            <a href="#home" data-toggle="tab">
                属性
            </a>
        </li>
    </ul>
    <div class="tab-pane fade in active" id="home">
        <form name="Tbluser_Properties" th:action="@{/Tbluser_Properties}"
              th:object="${tbluser_properties_entity}"
              method="post">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">属性</a>
                    </h4>
                </div>
                <div id="collapseOne" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <br/>

                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>用户:</label>
                                </div>
                                <div class="col-lg-8">
                                    <input class="form-control" th:field="*{UserId}"
                                           readonly name="UserId " maxlength="60" id="UserId">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label></label>
                                </div>
                                <div class="col-lg-8">
                                    <div th:if="${#fields.hasErrors('UserId')}"
                                         th:errors="${tbluser_properties_entity.UserId}"
                                         class="alert alert-danger">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div id="appendArea">

                        </div>

                    </div>


                </div>
                <br/>

                <br/>
            </div>


            <div class="row">
                <div class="col-lg-4"></div>
                <div class="col-lg-4" align="center">
                    <button type="reset" class="btn btn-primary">重 填</button>
                    <button type="button" onclick="submitPropertyValue()" class="btn btn-primary">保 存</button>
                </div>
                <div class="col-lg-4"></div>
            </div>

        </form>
    </div>
</div>


<script>

    var localData;
    $(document).ready(function () {
        $.ajax({
            url: "/Tbluser_Properties/loadBody",
            dataType: "json",
            asnyc: false,
            success: function (data) {
                localData = data;
                for (var i = 0; i < data.length; i++) {
                    $('#appendArea').append("<div class=\"row\">" +
                        "                            <div class=\"col-lg-6\">" +
                        "                                <div class=\"col-lg-4\">" +
                        "                                    <label>" + data[i].PropertiesId + "：</label>" +
                        "                                </div>" +
                        "                                <div class=\"col-lg-8\">" +
                        "                                    <input class=\"form-control\" th:field=\"*{" + data[i].PropertiesId + "}\"" +
                        "                                            name=\"" + data[i].PropertiesId + " \" maxlength=\"20\" id=\"" + data[i].PropertiesId + "\">" +
                        "                                </div>" +
                        "                            </div>" +
                        "                        </div><br/>");
//                    data[i].PropertiesId;
                }
            }
        });
    })

    function submitPropertyValue() {
        var propertyData = new Array();
        for (var i = 0; i < localData.length; i++) {
            propertyData.push(localData[i].PropertiesId, $('#' + localData[i].PropertiesId + '').val());
        }
        $.ajax({
            type: 'post',
            url: '/Tbluser_Properties/postCurrentUserInfo?UserId=' + $('#UserId').val(),
            contentType: 'application/json',
            data: JSON.stringify(propertyData),
            success: function (data) {
                alert("保存成功");
            },
            error: function () {
                alert("数据发送失败");
            }
        })
    }


</script>
</body>

</html>